﻿$(document).ready(function () {
    page.init();
});

var page = {
    url: "/handler/auction.ashx?action=",
    popU: null,

    init: function () {
        $(".top-bar .right li:eq(2)").addClass("current");

        if (page.currentAuction.Id == 0) {
            $("#errorPanel").show();
            return;
        }
        $("#info").show();
        page.getList();
    },

    getList: function () {
        $("#result").html(TrimPath.processDOMTemplate("auctionlist", page));
    },

    showBid: function (auctionId, auctionItemId) {
        var html = [];
        html.push("<div id='panelItem'></div>");

        page.popU = page.popU || new PopU();
        page.popU.initPop({
            type: 'string',
            title: "竞拍详情",
            contents: html.join(""),
            w: 600,
            y: $(window).scrollTop() + 30,
            drag: true
        });
        page.popU.showPop();

        var item;
        for (var i = 0; i < page.list.length; i++) {
            if (page.list[i].Id == auctionItemId) {
                item = page.list[i];
                break;
            }
        }

        $("#panelItem").html(TrimPath.processDOMTemplate("auction_detail", item));
    },

    getBid: function (auctionId, itemId) {
        $.post(page.url + "queryBid", { auctionId: auctionId, auctionItemId: itemId }, function (data) {
            $("#bilist").html(TrimPath.processDOMTemplate("bidlist", data));
        }, "json");
    }
};

